#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
struct ListNode {
    int val;
    struct ListNode* next;
};
typedef struct ListNode ListNode;
struct ListNode* getIntersectionNode(struct ListNode* headA, struct ListNode* headB)
{
    ListNode* cur1 = headA;
    ListNode* cur2 = headB;
    int len1 = 1, len2 = 1;
    while (cur1->next)
    {
        cur1 = cur1->next;
        len1++;
    }
    while (cur2->next)
    {
        cur2 = cur2->next;
        len2++;
    }
    if (cur1->val != cur2->val)
    {
        return NULL;
    }
    else
    {
        ListNode* pcur1 = headA;
        ListNode* pcur2 = headB;
        if (len1 >= len2)
        {
            int num = len1 - len2;
            while (num--)
            {
                pcur1 = pcur1->next;
            }
        }
        else
        {
            int num = len2 - len1;
            while (num--)
            {
                pcur2 = pcur2->next;
            }
        }
        while (pcur1)
        {
            if (pcur1->val == pcur2->val)
            {
                return pcur1;
            }
            pcur1 = pcur1->next;
            pcur2 = pcur2->next;
        }
    }
}
int main()
{

    return 0;
}